Skip to content

feat(settlement): add batch_receive_payment for multi-developer crediting - #369

Merged
greatest0fallt1me merged 2 commits into
CalloraOrg:mainfrom
Richardkingz2019:feature/settlement-batch-receive
May 27, 2026
Merged

feat(settlement): add batch_receive_payment for multi-developer crediting#369
greatest0fallt1me merged 2 commits into
CalloraOrg:mainfrom
Richardkingz2019:feature/settlement-batch-receive

Conversation

@Richardkingz2019

Copy link
Copy Markdown
Contributor

Summary

Closes #341

Adds batch_receive_payment(caller, items: Vec<(Address, i128)>) to CalloraSettlement, enabling atomic multi-developer crediting in a single call — mirroring the vault's batch_deduct and the revenue pool's batch_distribute patterns.

Changes

contracts/settlement/src/lib.rs

  • Added MAX_BATCH_SIZE = 50 constant (aligned with vault and revenue pool)
  • Added batch_receive_payment(caller, items):
    • Authorizes via existing require_authorized_caller (vault or admin)
    • Rejects empty batches and batches exceeding MAX_BATCH_SIZE
    • Validates all amounts > 0 before any state write (full atomicity)
    • Credits each developer balance using checked_add (overflow-safe)
    • Emits balance_credited event per leg

contracts/settlement/src/test.rs

Added 9 tests:

  • test_batch_receive_payment_credits_multiple_developers
  • test_batch_receive_payment_accumulates_existing_balance
  • test_batch_receive_payment_admin_caller_allowed
  • test_batch_receive_payment_rejects_empty_batch
  • test_batch_receive_payment_rejects_oversized_batch
  • test_batch_receive_payment_rejects_zero_amount
  • test_batch_receive_payment_rejects_negative_amount
  • test_batch_receive_payment_unauthorized_caller_rejected
  • test_batch_receive_payment_single_item
  • test_batch_receive_payment_max_batch_size_accepted

Testing

All 64 tests pass (cargo test -p callora-settlement), including all 9 new batch tests.

…ting

Closes CalloraOrg#341

- Add MAX_BATCH_SIZE = 50 constant (aligns with vault batch_deduct and
  revenue pool batch_distribute)
- Add batch_receive_payment(caller, items: Vec<(Address, i128)>) that:
  - Requires vault or admin caller via require_authorized_caller
  - Rejects empty batches and batches exceeding MAX_BATCH_SIZE
  - Validates all amounts > 0 before any state write (atomicity)
  - Credits each developer balance with checked_add
  - Emits balance_credited event per leg
- Add 9 tests covering: multi-dev credits, balance accumulation, admin
  caller, empty batch, oversized batch, zero/negative amounts,
  unauthorized caller, single item, and exact MAX_BATCH_SIZE
@drips-wave

drips-wave Bot commented May 27, 2026

Copy link
Copy Markdown

@Richardkingz2019 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@greatest0fallt1me
greatest0fallt1me merged commit d026e84 into CalloraOrg:main May 27, 2026
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Settlement: add batch_receive_payment for multi-developer crediting in one call

2 participants